import 'package:environmental_les_app/common/style/colours.dart';
import 'package:environmental_les_app/common/widgets/add_picture.dart';
import 'package:environmental_les_app/common/widgets/button_public_rect.dart';
import 'package:environmental_les_app/common/widgets/common_widget.dart';
import 'package:environmental_les_app/common/widgets/required_field_text.dart';
import 'package:environmental_les_app/common/widgets/text_area.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';

import 'index.dart';

class PatrolFillingPage extends GetView<PatrolFillingController> {
  const PatrolFillingPage({super.key});

  // 主视图
  Widget _buildView() {
    return Column(
      children: [
        Expanded(
          child: SingleChildScrollView(
            child: baseCardContainer(
              content: [
                operateRowItem(
                    title: "是否有问题",
                    content: "",
                    isRequired: true,
                    rightWidget: Row(
                      children: [
                        customRadio(
                          value: 1,
                          groupValue: controller.patrolType,
                          onChanged: (value) {
                            controller.patrolType = value!;
                            controller.update(["patrol_filling"]);
                          },
                          title: '是',
                        ),
                        hGap20,
                        customRadio(
                          value: 2,
                          groupValue: controller.patrolType,
                          onChanged: (value) {
                            controller.patrolType = value!;
                            controller.update(["patrol_filling"]);
                          },
                          title: '否',
                        ),
                      ],
                    ),
                    showLine: true),
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    vGap10,
                    const RequiredFieldText(
                      text: "排查情况",
                      titleColor: Colours.text969,
                      titleFontSize: 15,
                      titleFontWeight: FontWeight.w400,
                    ),
                    vGap16,
                    TextArea(
                      controller: TextEditingController(),
                      hintText: "请输入内容",
                      minLines: 5,
                      maxLines: 5,
                      maxLength: 500,
                    ),
                  ],
                ),
                vGap10,
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    vGap10,
                    const RequiredFieldText(
                      text: "处理措施",
                      titleColor: Colours.text969,
                      titleFontSize: 15,
                      titleFontWeight: FontWeight.w400,
                    ),
                    vGap16,
                    TextArea(
                      controller: TextEditingController(),
                      hintText: "请输入内容",
                      minLines: 2,
                      maxLines: 5,
                      maxLength: 200,
                    ),
                  ],
                ),
                vGap10,
                const Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    vGap16,
                    Text("影像信息",
                        style: TextStyle(fontSize: 15, color: Colours.text969)),
                    vGap10,
                    AddPictureWidget(num: 6, imageList: []),
                  ],
                ),
              ],
            ),
          ),
        ),
        Container(
          padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
          child: Row(
            children: [
              Expanded(
                  child: ButtonPublicRect(
                text: "提交",
                onPressed: () {},
              )),
              hGap10,
              Expanded(
                  child: ButtonPublicRect(
                type: ButtonPublicType.outline,
                text: "取消",
                onPressed: () {},
              )),
            ],
          ),
        )
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<PatrolFillingController>(
      init: PatrolFillingController(),
      id: "patrol_filling",
      builder: (_) {
        return MyScaffold(
          title: "巡查填报",
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
